﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Objects;
using System.Linq;
using System.Text;
using Shared;

namespace DAL
{
    /// <summary>
    /// Interaction logic with the database
    /// </summary>
    public class DataAccessLayer : IDataAccessLayer
    {
        /// <summary>
        /// Entity object to be used to access to the database
        /// </summary>
        private OficinaTuristicaEntities1 entities;
                
        /// <summary>
        /// Method that returns a list with the differents activities that will be separated
        /// in containers
        /// </summary>
        /// <returns>List of GroupSets</returns>
        public List<GroupsSet> GetServiceList()
        {
            if (entities == null) entities = new OficinaTuristicaEntities1();

            ObjectQuery<GroupsSet> allservices = entities.GroupsSet;

            allservices.MergeOption = MergeOption.NoTracking;

            var query = from c in allservices
                        select c;

            List<GroupsSet> results = query.ToList();

            return results;

        }
        /// <summary>
        /// Gets all the Private Services listed in the database
        /// </summary>
        /// <returns>List of Items</returns>
        public List<Item> GetPrivateServiceItems()
        {
            if (entities == null) entities = new OficinaTuristicaEntities1();

            ObjectQuery<PrivateServices> allPrivateServices = entities.PrivateServices;

            allPrivateServices.MergeOption = MergeOption.NoTracking;

            var query = from c in allPrivateServices
                        select new Item 
                        { 
                            Address = c.Address, 
                            CompanyName = c.Name, 
                            Description1 = c.Description1, 
                            Description2 = c.Description2,
                            Description3 = c.Description3, 
                            Description4 = c.Description4, 
                            Email = c.Email, //Image = c.Photos, 
                            Latitude = c.Latitude, 
                            Longitude = c.Longitude,
                            PrimaryPhone = c.PrimaryPhone, 
                            SecondaryPhone = c.SecondaryPhone, 
                            Web = c.Web
                        };
                        
            return query.ToList();
        }
        /// <summary>
        /// Gets all the Sports providers listed in the database
        /// </summary>
        /// <returns>List of Items</returns>
        public List<Item> GetSportsItems()
        {
            if (entities == null) entities = new OficinaTuristicaEntities1();

            ObjectQuery<Sports> allPrivateServices = entities.Sports;

            allPrivateServices.MergeOption = MergeOption.NoTracking;

            var query = from c in allPrivateServices
                        select new Item
                        {
                            Address = c.Address,
                            CompanyName = c.Name,
                            Description1 = c.Description1,
                            Description2 = c.Description2,
                            Description3 = c.Description3,
                            Description4 = c.Description4,
                            Email = c.Email,
                            Image = c.Photos,
                            Latitude = c.Latitude,
                            Longitude = c.Longitude,
                            PrimaryPhone = c.PrimaryPhone,
                            SecondaryPhone = c.SecondaryPhone,
                            Web = c.Web
                        };

            return query.ToList();
        }
        /// <summary>
        /// Gets all the Lodging places listed in the database
        /// </summary>
        /// <returns>List of Items</returns>
        public List<Item> GetLodgingItems()
        {
            if (entities == null) entities = new OficinaTuristicaEntities1();

            ObjectQuery<Lodging> allPrivateServices = entities.Lodging;

            allPrivateServices.MergeOption = MergeOption.NoTracking;

            var query = from c in allPrivateServices
                        select new Item
                        {
                            Address = c.Address,
                            CompanyName = c.Name,
                            Description1 = c.Description1,
                            Description2 = c.Description2,
                            Description3 = c.Description3,
                            Description4 = c.Description4,
                            Email = c.Email,
                            Image = c.Photos,
                            Latitude = c.Latitude,
                            Longitude = c.Longitude,
                            PrimaryPhone = c.PrimaryPhone,
                            SecondaryPhone = c.SecondaryPhone,
                            Web = c.Web
                        };

            return query.ToList();
        }
        /// <summary>
        /// Gets all the Bars, Restaurants & Pubs listed in the database
        /// </summary>
        /// <returns>List of Items</returns>
        public List<Item> GetBarsItems()
        {
            if (entities == null) entities = new OficinaTuristicaEntities1();

            ObjectQuery<Bars_Restaurants> allPrivateServices = entities.Bars_Restaurants;

            allPrivateServices.MergeOption = MergeOption.NoTracking;

            var query = from c in allPrivateServices
                        select new Item
                        {
                            Address = c.Address,
                            CompanyName = c.Name,
                            Description1 = c.Description1,
                            Description2 = c.Description2,
                            Description3 = c.Description3,
                            Description4 = c.Description4,
                            Email = c.Email,
                            Image = c.Photos,
                            Latitude = c.Latitude,
                            Longitude = c.Longitude,
                            PrimaryPhone = c.PrimaryPhone,
                            SecondaryPhone = c.SecondaryPhone,
                            Web = c.Web
                        };

            return query.ToList();
        }
        /// <summary>
        /// Gets all the leisure providers listed in the database
        /// </summary>
        /// <returns>List of Items</returns>
        public List<Item> GetLeisureItems()
        {
            if (entities == null) entities = new OficinaTuristicaEntities1();

            ObjectQuery<Leisure> allPrivateServices = entities.Leisure;

            allPrivateServices.MergeOption = MergeOption.NoTracking;

            var query = from c in allPrivateServices
                        select new Item
                        {
                            Address = c.Address,
                            CompanyName = c.Name,
                            Description1 = c.Description1,
                            Description2 = c.Description2,
                            Description3 = c.Description3,
                            Description4 = c.Description4,
                            Email = c.Email,
                            Image = c.Photos,
                            Latitude = c.Latitude,
                            Longitude = c.Longitude,
                            PrimaryPhone = c.PrimaryPhone,
                            SecondaryPhone = c.SecondaryPhone,
                            Web = c.Web
                        };

            return query.ToList();
        }

        /// <summary>
        /// Gets all the places where to shop listed in the database
        /// </summary>
        /// <returns>List of Items</returns>
        public List<Item> GetShoppingItems()
        {
            if (entities == null) entities = new OficinaTuristicaEntities1();

            ObjectQuery<Shopping> allPrivateServices = entities.Shopping;

            allPrivateServices.MergeOption = MergeOption.NoTracking;

            var query = from c in allPrivateServices
                        select new Item
                        {
                            Address = c.Address,
                            CompanyName = c.Name,
                            Description1 = c.Description1,
                            Description2 = c.Description2,
                            Description3 = c.Description3,
                            Description4 = c.Description4,
                            Email = c.Email,
                            Image = c.Photos,
                            Latitude = c.Latitude,
                            Longitude = c.Longitude,
                            PrimaryPhone = c.PrimaryPhone,
                            SecondaryPhone = c.SecondaryPhone,
                            Web = c.Web
                        };

            return query.ToList();
        }
        /// <summary>
        /// Gets all the tourist attractions listed in the database
        /// </summary>
        /// <returns>List of Items</returns>
        public List<Item> GetTouristAttractionsItems()
        {
            if (entities == null) entities = new OficinaTuristicaEntities1();

            ObjectQuery<PointsOfTouristInterest> allPrivateServices = entities.PointsOfTouristInterest;

            allPrivateServices.MergeOption = MergeOption.NoTracking;

            var query = from c in allPrivateServices
                        select new Item
                        {
                            Address = c.Address,
                            CompanyName = c.Name,
                            Description1 = c.Description1,
                            Description2 = c.Description2,
                            Description3 = c.Description3,
                            Description4 = c.Description4,
                            Image = c.Photos,
                            Latitude = c.Latitude,
                            Longitude = c.Longitude,
                            PrimaryPhone = c.PrimaryPhone,
                            SecondaryPhone = c.SecondaryPhone,
                            Web = c.Web
                        };

            return query.ToList();
        }
        /// <summary>
        /// Gets all the Private Services listed in the database
        /// </summary>
        /// <returns>List of Items</returns>
        public List<Item> GetRoutesItems()
        {
            if (entities == null) entities = new OficinaTuristicaEntities1();

            ObjectQuery<Routes> allPrivateServices = entities.Routes;

            allPrivateServices.MergeOption = MergeOption.NoTracking;

            var query = from c in allPrivateServices
                        select new Item
                        {
                            Address = c.Address,
                            CompanyName = c.Name,
                            Description1 = c.Description1,
                            Description2 = c.Description2,
                            Description3 = c.Description3,
                            Description4 = c.Description4,
                            Email = c.Email,
                            Image = c.Photos,
                            Latitude = c.Latitude,
                            Longitude = c.Longitude,
                            PrimaryPhone = c.PrimaryPhone,
                            SecondaryPhone = c.SecondaryPhone,
                            Web = c.Web
                        };

            return query.ToList();
        }
        /// <summary>
        /// Gets all the Telephones of interest listed in the database
        /// </summary>
        /// <returns>List of Items</returns>
        public List<Item> GetTelephonesItems()
        {
            if (entities == null) entities = new OficinaTuristicaEntities1();

            ObjectQuery<TelephonesOfInterest> allPrivateServices = entities.TelephonesOfInterest;

            allPrivateServices.MergeOption = MergeOption.NoTracking;

            var query = from c in allPrivateServices
                        select new Item
                        {
                            Address = c.Address,
                            CompanyName = c.Name,
                            Description1 = c.Description1,
                            Description2 = c.Description2,
                            Description3 = c.Description3,
                            Description4 = c.Description4,
                            Latitude = c.Latitude,
                            Longitude = c.Longitude,
                            PrimaryPhone = c.PrimaryPhone,
                            SecondaryPhone = c.SecondaryPhone,
                            Web = c.Web
                        };

            return query.ToList();
        }
        /// <summary>
        /// Gets all the transport providers listed in the database
        /// </summary>
        /// <returns>List of Items</returns>
        public List<Item> GetTransportItems()
        {
            if (entities == null) entities = new OficinaTuristicaEntities1();

            ObjectQuery<Transport> allPrivateServices = entities.Transport;

            allPrivateServices.MergeOption = MergeOption.NoTracking;

            var query = from c in allPrivateServices
                        select new Item
                        {
                            Address = c.Address,
                            CompanyName = c.Name,
                            Description1 = c.Description1,
                            Description2 = c.Description2,
                            Description3 = c.Description3,
                            Description4 = c.Description4,
                            Latitude = c.Latitude,
                            Longitude = c.Longitude,
                            PrimaryPhone = c.PrimaryPhone,
                            SecondaryPhone = c.SecondaryPhone,
                            Web = c.Web,

                        };

            return query.ToList();
        }
        /// <summary>
        /// Gets the details of an specified item 
        /// </summary>
        /// <returns>Item</returns>
        public Item GetItemDetails(string serviceType, string Name, int language)
        {
            Item itemDetails = new Item();

            if (entities == null) entities = new OficinaTuristicaEntities1();            

            //TODO: Completar la funció per que retorni els detalls del item seleccionat.
            // El problema es quin parámetres s'han de pasar a la funció.

            switch (serviceType)
            {
                case "PrivateServices":
                    
                    ObjectQuery<PrivateServices> itemPrivateServiceRequest = entities.PrivateServices;
                    itemPrivateServiceRequest.MergeOption = MergeOption.NoTracking;
                    var query = from c in itemPrivateServiceRequest
                                where c.Name == Name
                                select c;
                    
                    List<PrivateServices> results = query.ToList();
                    if (results != null)
                    {
                        itemDetails.CompanyName = results[0].Name;
                        itemDetails.Address = results[0].Address;
                        itemDetails.Email = results[0].Email;
                        itemDetails.PrimaryPhone = results[0].PrimaryPhone;
                        itemDetails.Image = results[0].Photos;
                        itemDetails.Web = results[0].Web;
                        itemDetails.Latitude = results[0].Latitude;
                        itemDetails.Longitude = results[0].Longitude;
                        itemDetails.serviceType = results[0].EntityKey.EntitySetName;
                        
                        switch (language)
                        {
                            case 0:
                                itemDetails.Description = results[0].Description1;
                                break;
                            case 1:
                                itemDetails.Description = results[0].Description2;
                                break;
                            case 2:
                                itemDetails.Description = results[0].Description3;
                                break;
                            case 3:
                                itemDetails.Description = results[0].Description4;
                                break;
                        }                                
                        
                    }
                    return itemDetails;

                case "Sports":
                    ObjectQuery<Sports> itemSportRequest = entities.Sports;
                    itemSportRequest.MergeOption = MergeOption.NoTracking;
                    var query1 = from c in itemSportRequest
                                where c.Name == Name
                                select c;

                    List<Sports> results1 = query1.ToList();
                    if (results1 != null)
                    {
                        itemDetails.CompanyName = results1[0].Name;
                        itemDetails.Address = results1[0].Address;
                        itemDetails.Email = results1[0].Email;
                        itemDetails.PrimaryPhone = results1[0].PrimaryPhone;
                        itemDetails.Image = results1[0].Photos;
                        itemDetails.Web = results1[0].Web;
                        itemDetails.Latitude = results1[0].Latitude;
                        itemDetails.Longitude = results1[0].Longitude;
                        itemDetails.serviceType = results1[0].EntityKey.EntitySetName;
                        if (!string.IsNullOrEmpty(results1[0].Video )) itemDetails.VideoSource = new Uri(results1[0].Video);
                        switch (language)
                        {
                            case 0:
                                itemDetails.Description = results1[0].Description1;
                                break;
                            case 1:
                                itemDetails.Description = results1[0].Description2;
                                break;
                            case 2:
                                itemDetails.Description = results1[0].Description3;
                                break;
                            case 3:
                                itemDetails.Description = results1[0].Description4;
                                break;
                        } 
                    }
                    return itemDetails;

                case "Lodging":
                    ObjectQuery<Lodging> itemLodgingRequest = entities.Lodging;
                    itemLodgingRequest.MergeOption = MergeOption.NoTracking;
                    var query2 = from c in itemLodgingRequest
                                where c.Name == Name
                                select c;

                    List<Lodging> results2 = query2.ToList();
                    if (results2 != null)
                    {
                        itemDetails.CompanyName = results2[0].Name;
                        itemDetails.Address = results2[0].Address;
                        itemDetails.Email = results2[0].Email;
                        itemDetails.PrimaryPhone = results2[0].PrimaryPhone;
                        itemDetails.Image = results2[0].Photos;
                        itemDetails.Web = results2[0].Web;
                        itemDetails.Latitude = results2[0].Latitude;
                        itemDetails.Longitude = results2[0].Longitude;
                        itemDetails.serviceType = results2[0].EntityKey.EntitySetName;
                        if (!string.IsNullOrEmpty(results2[0].Video )) itemDetails.VideoSource = new Uri(results2[0].Video);
                        switch (language)
                        {
                            case 0:
                                itemDetails.Description = results2[0].Description1;
                                break;
                            case 1:
                                itemDetails.Description = results2[0].Description2;
                                break;
                            case 2:
                                itemDetails.Description = results2[0].Description3;
                                break;
                            case 3:
                                itemDetails.Description = results2[0].Description4;
                                break;
                        } 
                    }
                    return itemDetails;

                case "Bars_Restaurants":
                    ObjectQuery<Bars_Restaurants> itemBarRequest = entities.Bars_Restaurants;
                    itemBarRequest.MergeOption = MergeOption.NoTracking;
                    var query3 = from c in itemBarRequest
                                where c.Name == Name
                                select c;

                    List<Bars_Restaurants> results3 = query3.ToList();
                    if (results3 != null)
                    {
                        itemDetails.CompanyName = results3[0].Name;
                        itemDetails.Address = results3[0].Address;
                        itemDetails.Email = results3[0].Email;
                        itemDetails.PrimaryPhone = results3[0].PrimaryPhone;
                        itemDetails.Image = results3[0].Photos;
                        itemDetails.Web = results3[0].Web;
                        itemDetails.Latitude = results3[0].Latitude;
                        itemDetails.Longitude = results3[0].Longitude;
                        itemDetails.serviceType = results3[0].EntityKey.EntitySetName;
                        if (!string.IsNullOrEmpty( results3[0].Video )) itemDetails.VideoSource = new Uri(results3[0].Video);
                        switch (language)
                        {
                            case 0:
                                itemDetails.Description = results3[0].Description1;
                                break;
                            case 1:
                                itemDetails.Description = results3[0].Description2;
                                break;
                            case 2:
                                itemDetails.Description = results3[0].Description3;
                                break;
                            case 3:
                                itemDetails.Description = results3[0].Description4;
                                break;
                        } 
                    }
                    return itemDetails;

                case "Leisure":
                    ObjectQuery<Leisure> itemLeisureRequest = entities.Leisure;
                    itemLeisureRequest.MergeOption = MergeOption.NoTracking;
                    var query4 = from c in itemLeisureRequest
                                where c.Name == Name
                                select c;

                    List<Leisure> results4 = query4.ToList();
                    if (results4 != null)
                    {
                        itemDetails.CompanyName = results4[0].Name;
                        itemDetails.Address = results4[0].Address;
                        itemDetails.Email = results4[0].Email;
                        itemDetails.PrimaryPhone = results4[0].PrimaryPhone;
                        itemDetails.Image = results4[0].Photos;
                        itemDetails.Web = results4[0].Web;
                        itemDetails.Latitude = results4[0].Latitude;
                        itemDetails.Longitude = results4[0].Longitude;
                        if (!string.IsNullOrEmpty(results4[0].Video)) itemDetails.VideoSource = new Uri(results4[0].Video);
                        itemDetails.serviceType = results4[0].EntityKey.EntitySetName;
                        switch (language)
                        {
                            case 0:
                                itemDetails.Description = results4[0].Description1;
                                break;
                            case 1:
                                itemDetails.Description = results4[0].Description2;
                                break;
                            case 2:
                                itemDetails.Description = results4[0].Description3;
                                break;
                            case 3:
                                itemDetails.Description = results4[0].Description4;
                                break;
                        } 
                    }
                    return itemDetails;
                    

                case "Shopping":
                    ObjectQuery<Shopping> itemShoppingRequest = entities.Shopping;                    
                    itemShoppingRequest.MergeOption = MergeOption.NoTracking;                    
                   
                    var query5 = from c in itemShoppingRequest
                                where c.Name == Name
                                select c;

                    List<Shopping> results5 = query5.ToList();
                    if (results5 != null)
                    {
                        itemDetails.CompanyName = results5[0].Name;
                        itemDetails.Address = results5[0].Address;
                        itemDetails.Email = results5[0].Email;
                        itemDetails.PrimaryPhone = results5[0].PrimaryPhone;
                        itemDetails.Image = results5[0].Photos;
                        itemDetails.Web = results5[0].Web;
                        itemDetails.Latitude = results5[0].Latitude;
                        itemDetails.Longitude = results5[0].Longitude;
                        itemDetails.serviceType = results5[0].EntityKey.EntitySetName;
                        if (!string.IsNullOrEmpty(results5[0].Video ))
                        {
                            itemDetails.VideoSource = new Uri(results5[0].Video);
                        }
                        switch (language)
                        {
                            case 0:
                                itemDetails.Description = results5[0].Description1;
                                break;
                            case 1:
                                itemDetails.Description = results5[0].Description2;
                                break;
                            case 2:
                                itemDetails.Description = results5[0].Description3;
                                break;
                            case 3:
                                itemDetails.Description = results5[0].Description4;
                                break;
                        } 
                    }
                    return itemDetails;

                case "PointsOfTouristInterest":
                    ObjectQuery<PointsOfTouristInterest> itemPointsOfTouristInterestRequest = entities.PointsOfTouristInterest;
                    itemPointsOfTouristInterestRequest.MergeOption = MergeOption.NoTracking;
                    var query6 = from c in itemPointsOfTouristInterestRequest
                                where c.Name == Name
                                select c;

                    List<PointsOfTouristInterest> results6 = query6.ToList();
                    if (results6 != null)
                    {
                        itemDetails.CompanyName = results6[0].Name;
                        itemDetails.Address = results6[0].Address;
                       // itemDetails.Email = results6[0].Email;
                        itemDetails.PrimaryPhone = results6[0].PrimaryPhone;
                        itemDetails.Image = results6[0].Photos;
                        itemDetails.Web = results6[0].Web;
                        itemDetails.Latitude = results6[0].Latitude;
                        itemDetails.Longitude = results6[0].Longitude;
                        itemDetails.serviceType = results6[0].EntityKey.EntitySetName;
                        if (!string.IsNullOrEmpty(results6[0].Video )) itemDetails.VideoSource = new Uri(results6[0].Video);
                        switch (language)
                        {
                            case 0:
                                itemDetails.Description = results6[0].Description1;
                                break;
                            case 1:
                                itemDetails.Description = results6[0].Description2;
                                break;
                            case 2:
                                itemDetails.Description = results6[0].Description3;
                                break;
                            case 3:
                                itemDetails.Description = results6[0].Description4;
                                break;
                        } 
                    }
                    return itemDetails;

                case "Routes":
                    ObjectQuery<Routes> itemRoutesRequest = entities.Routes;
                    itemRoutesRequest.MergeOption = MergeOption.NoTracking;
                    var query7 = from c in itemRoutesRequest
                                where c.Name == Name
                                select c;

                    List<Routes> results7 = query7.ToList();
                    if (results7 != null)
                    {
                        itemDetails.CompanyName = results7[0].Name;
                        itemDetails.Address = results7[0].Address;
                        itemDetails.Email = results7[0].Email;
                        itemDetails.PrimaryPhone = results7[0].PrimaryPhone;
                        itemDetails.Image = results7[0].Photos;
                        itemDetails.Web = results7[0].Web;
                        itemDetails.Latitude = results7[0].Latitude;
                        itemDetails.Longitude = results7[0].Longitude;
                        itemDetails.serviceType = results7[0].EntityKey.EntitySetName;
                        if (!string.IsNullOrEmpty(results7[0].Video )) itemDetails.VideoSource = new Uri(results7[0].Video);
                        itemDetails.Route = results7[0].GPSFile;
                        switch (language)
                        {
                            case 0:
                                itemDetails.Description = results7[0].Description1;
                                break;
                            case 1:
                                itemDetails.Description = results7[0].Description2;
                                break;
                            case 2:
                                itemDetails.Description = results7[0].Description3;
                                break;
                            case 3:
                                itemDetails.Description = results7[0].Description4;
                                break;
                        } 
                    }
                    return itemDetails;

                case "TelephoneOfInterest":
                    ObjectQuery<TelephonesOfInterest> itemPhoneNumberRequest = entities.TelephonesOfInterest;
                    itemPhoneNumberRequest.MergeOption = MergeOption.NoTracking;
                    var query8 = from c in itemPhoneNumberRequest
                                where c.Name == Name
                                select c;

                    List<TelephonesOfInterest> results8 = query8.ToList();
                    if (results8 != null)
                    {
                        itemDetails.CompanyName = results8[0].Name;
                        itemDetails.Address = results8[0].Address;
                      //  itemDetails.Email = results8[0].Email;
                        itemDetails.PrimaryPhone = results8[0].PrimaryPhone;
                       // itemDetails.Image = results8[0].Photos;
                        itemDetails.Web = results8[0].Web;
                        itemDetails.Latitude = results8[0].Latitude;
                        itemDetails.Longitude = results8[0].Longitude;
                        itemDetails.serviceType = results8[0].EntityKey.EntitySetName;
                        switch (language)
                        {
                            case 0:
                                itemDetails.Description = results8[0].Description1;
                                break;
                            case 1:
                                itemDetails.Description = results8[0].Description2;
                                break;
                            case 2:
                                itemDetails.Description = results8[0].Description3;
                                break;
                            case 3:
                                itemDetails.Description = results8[0].Description4;
                                break;
                        } 
                    }
                    return itemDetails;

                case "Transport":
                    ObjectQuery<Transport> itemTransportRequest = entities.Transport;
                    itemTransportRequest.MergeOption = MergeOption.NoTracking;
                   
                    var query9 = from c in itemTransportRequest
                                where c.Name == Name
                                select c;

                    List<Transport> results9 = query9.ToList();
                    if (results9 != null)
                    {
                        itemDetails.CompanyName = results9[0].Name;
                        itemDetails.Address = results9[0].Address;
                       // itemDetails.Email = results9[0].Email;
                        itemDetails.PrimaryPhone = results9[0].PrimaryPhone;
                       // itemDetails.Image = results9[0].Photos;
                        itemDetails.Web = results9[0].Web;
                        itemDetails.Latitude = results9[0].Latitude;
                        itemDetails.Longitude = results9[0].Longitude;
                        itemDetails.serviceType = results9[0].EntityKey.EntitySetName;
                        switch (language)
                        {
                            case 0:
                                itemDetails.Description = results9[0].Description1;
                                break;
                            case 1:
                                itemDetails.Description = results9[0].Description2;
                                break;
                            case 2:
                                itemDetails.Description = results9[0].Description3;
                                break;
                            case 3:
                                itemDetails.Description = results9[0].Description4;
                                break;
                        } 
                    }
                    return itemDetails;                
            }       
            return itemDetails;
        }       
    }
}
